﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using webapi.Models;
using System.Text;
using System.Web;
using System.Web.Mvc;

namespace webapi.Controllers
{
    public class AppsController : ApiController
    {

        App[] apps = new App[]
        {
            new App { Id = "1", Name = "1",Type="soft", Url = "/#1", Img = "assets/icon/1.png" },
            new App { Id = "2", Name = "2",Type="soft", Url = "/#2", Img = "assets/icon/2.png" },
            new App { Id = "3", Name = "3",Type="soft", Url = "/#3", Img = "assets/icon/3.png" },
            new App { Id = "4", Name = "4",Type="soft", Url = "/#4", Img = "assets/icon/4.png" },
            new App { Id = "5", Name = "5",Type="soft", Url = "/#4", Img = "assets/icon/5.png" },
            new App { Id = "6", Name = "6",Type="soft", Url = "/#4", Img = "assets/icon/6.png" },
            new App { Id = "7", Name = "7",Type="soft", Url = "/#4", Img = "assets/icon/7.png" },
            new App { Id = "8", Name = "8",Type="soft", Url = "/#4", Img = "assets/icon/8.png" },
            new App { Id = "9", Name = "9",Type="soft", Url = "/#4", Img = "assets/icon/9.png" },
            new App { Id = "10", Name = "10",Type="soft", Url = "/#4", Img = "assets/icon/10.png" },
            new App { Id = "11", Name = "11",Type="game", Url = "/#4", Img = "assets/icon/11.png" },
            new App { Id = "12", Name = "12",Type="game", Url = "/#4", Img = "assets/icon/12.png" },
            new App { Id = "13", Name = "13",Type="game", Url = "/#4", Img = "assets/icon/13.png" },
            new App { Id = "14", Name = "14",Type="game", Url = "/#4", Img = "assets/icon/14.png" },
            new App { Id = "15", Name = "15",Type="game", Url = "/#4", Img = "assets/icon/15.png" },
            new App { Id = "16", Name = "16",Type="game", Url = "/#4", Img = "assets/icon/16.png" },
            new App { Id = "17", Name = "17",Type="game", Url = "/#4", Img = "assets/icon/17.png" },
            new App { Id = "18", Name = "18",Type="game", Url = "/#4", Img = "assets/icon/18.png" },
            new App { Id = "19", Name = "19",Type="game", Url = "/#4", Img = "assets/icon/19.png" },
            new App { Id = "20", Name = "20",Type="game", Url = "/#4", Img = "assets/icon/20.png" },
            new App { Id = "21", Name = "21",Type="video", Url = "/#4", Img = "assets/icon/21.png" },
            new App { Id = "22", Name = "22",Type="video", Url = "/#4", Img = "assets/icon/22.png" },
            new App { Id = "23", Name = "23",Type="video", Url = "/#4", Img = "assets/icon/23.png" },
            new App { Id = "24", Name = "24",Type="video", Url = "/#4", Img = "assets/icon/24.png" },
            new App { Id = "25", Name = "25",Type="video", Url = "/#4", Img = "assets/icon/25.png" },
            new App { Id = "26", Name = "26",Type="video", Url = "/#4", Img = "assets/icon/26.png" },
            new App { Id = "27", Name = "27",Type="video", Url = "/#4", Img = "assets/icon/27.png" },
            new App { Id = "28", Name = "28",Type="video", Url = "/#4", Img = "assets/icon/28.png" },
            new App { Id = "29", Name = "29",Type="video", Url = "/#4", Img = "assets/icon/29.png" },
            new App { Id = "30", Name = "30",Type="video", Url = "/#4", Img = "assets/icon/30.png" },
        };

        public IEnumerable<App> GetAllApps()
        {
            return apps;
        }

        //public IHttpActionResult GetApp(string id)
        //{
        //    var app = apps.FirstOrDefault((p) => p.Id == id);
        //    if (app == null)
        //    {
        //        return NotFound();
        //    }
        //    return Ok(app);
        //}

        public IHttpActionResult GetApp(string id)
        {
            var app = apps.Where((p) => p.Type == id);
            if (app == null)
            {
                return NotFound();
            }
            return Ok(app);
        }


    }
}
